Skip to content

[stable32] fix(security): don't propagate ValueError from Crypto::decrypt() fallback#61103

Open
backportbot[bot] wants to merge 1 commit into
stable32from
backport/60735/stable32
Open

[stable32] fix(security): don't propagate ValueError from Crypto::decrypt() fallback#61103
backportbot[bot] wants to merge 1 commit into
stable32from
backport/60735/stable32

Conversation

@backportbot

@backportbot backportbot Bot commented Jun 9, 2026

Copy link
Copy Markdown

Backport of PR #60735

…back

When decrypting a v3 ciphertext with a mismatched secret, the first
attempt throws an Exception (HMAC mismatch). The fallback then calls
decryptWithoutSecret() with an empty string, which causes hash_hkdf()
to throw a ValueError. Since ValueError extends \Error rather than
\Exception, it bypassed the catch block and propagated as an unhandled
error, crashing the whole request.

Wrap the fallback in its own try/catch(\Throwable) and rethrow the
original Exception so callers get a meaningful HMAC mismatch error.

Signed-off-by: Anna Larch <anna@nextcloud.com>
AI-Assisted-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@backportbot backportbot Bot requested a review from a team as a code owner June 9, 2026 13:14
@backportbot backportbot Bot requested review from ArtificialOwl, come-nc, leftybournes, miaulalala, nickvergessen, provokateurin and salmart-dev and removed request for a team June 9, 2026 13:14
@backportbot backportbot Bot added this to the Nextcloud 32.0.12 milestone Jun 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants